/**    
 * 文件名：RimCoreRoleLink.java    
 *    
 * 版本信息：    
 * 日期：2010-11-16    
 * Copyright  Corporation 2010     
 * 版权所有    
 *    
 */

package com.sunwayhorizo.health.hl7.persistent;

import java.io.Serializable;
import java.sql.Timestamp;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import com.sunwayhorizo.health.common.DataTypeUtil;
import com.sunwayhorizo.health.hl7.common.Hl7Exception;
import com.sunwayhorizo.health.hl7.datatypes.CS;
import com.sunwayhorizo.health.hl7.datatypes.INT;
import com.sunwayhorizo.health.hl7.datatypes.IVL_TS;
import com.sunwayhorizo.health.hl7.datatypes.PQ;
import com.sunwayhorizo.health.hl7.persistent.pk.RimCoreRoleLinkPK;

/**
 * @Title: RimCoreRoleLink.java
 * @Package com.sunwayhorizo.health.hl7.persistent
 * @Description:roleLink实体类
 * @version V1.0
 * @firstAuthor jinzw
 * @firstTime 2010-11-16 下午03:11:46
 * @lastAuthor jinzw
 * @lastTime 2010-11-16 下午03:11:46
 */

@Entity
@TableGenerator(name = "RoleLink_IdGenerator", table = "RIM_Id_Generator", pkColumnName = "pkColumn", valueColumnName = "valueColumn", pkColumnValue = "RoleLink_Id")
@DiscriminatorColumn(name = "PARTITION_BY_CLASS", discriminatorType = DiscriminatorType.STRING)
@DiscriminatorValue("RimCoreRoleLink")
@Table(name = "RIM_CORE_ROLE_LINK")
@IdClass(RimCoreRoleLinkPK.class)
public class RimCoreRoleLink implements Serializable
{

    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "RoleLink_IdGenerator")
    @Column(name = "ROLELINK_ID", nullable = false)
    private Long roleLinkId;
//    @Id
//    @Column(name = "SOURCE_ROLE_VER_NUM", nullable = false, insertable = false, updatable = false)
//    private Long sourceRoleVerNum = 1L;
//    @Id
//    @Column(name = "TARGET_ROLE_VER_NUM", nullable = false, insertable = false, updatable = false)
//    private Long targetRoleVerNum = 1L;

    @ManyToOne
    @JoinColumns({ @JoinColumn(name = "CNTRL_ACT_ID", referencedColumnName = "ACT_ID"),
            @JoinColumn(name = "CNTRL_ACT_VERSION_NUM", referencedColumnName = "ACT_VERSION_NUM") })
    private RimCoreActs controlAct;

    @ManyToOne
    @JoinColumns({ @JoinColumn(name = "SOURCE_ROLE_ID", referencedColumnName = "ROLE_ID"),
            @JoinColumn(name = "SOURCE_ROLE_VER_NUM", referencedColumnName = "ROLE_VERSION_NUM") })
    private RimCoreRoles sourceRole;

    @ManyToOne
    @JoinColumns({ @JoinColumn(name = "TARGET_ROLE_ID", referencedColumnName = "ROLE_ID"),
            @JoinColumn(name = "TARGET_ROLE_VER_NUM", referencedColumnName = "ROLE_VERSION_NUM") })
    private RimCoreRoles targetRole;


    /**
     * 具有权威的唯一名称类型 例如身份证，军官证，护照，家庭关系等等 与RimCoreEntyCdSets是单向一对一
     * 
     * @author jinzw
     * @date 2010-11-12
     */
    /*
     * @OneToOne
     * 
     * @JoinColumns({
     * 
     * @JoinColumn(name = "ENTY_ID", referencedColumnName = "ENTITY_ID"),
     * 
     * @JoinColumn(name = "ENTY_VERSION_NUM", referencedColumnName =
     * "ENTITY_VERSION_NUM"),
     * 
     * @JoinColumn(name = "ENTITY_CODE_SET_ID", referencedColumnName =
     * "ENTITY_CODE_SET_ID") }) private RimCoreEntyCdSets rimCoreEntyCdSets;
     */

    /*
     * public RimCoreEntyCdSets getRimCoreEntyCdSets() { return
     * rimCoreEntyCdSets; }
     * 
     * public void setRimCoreEntyCdSets(RimCoreEntyCdSets rimCoreEntyCdSets) {
     * this.rimCoreEntyCdSets = rimCoreEntyCdSets; }
     */

//    private Long getSourceRoleVerNum()
//    {
//        return sourceRoleVerNum;
//    }
//
//
//    private void setSourceRoleVerNum(Long sourceRoleVerNum)
//    {
//        this.sourceRoleVerNum = sourceRoleVerNum;
//    }
//
//
//    private Long getTargetRoleVerNum()
//    {
//        return targetRoleVerNum;
//    }
//
//
//    private void setTargetRoleVerNum(Long targetRoleVerNum)
//    {
//        this.targetRoleVerNum = targetRoleVerNum;
//    }


    public RimCoreRoles getSourceRole()
    {
        return sourceRole;
    }


    public void setSourceRole(RimCoreRoles sourceRole)
    {
        this.sourceRole = sourceRole;
    }


    public RimCoreRoles getTargetRole()
    {
        return targetRole;
    }


    public void setTargetRole(RimCoreRoles targetRole)
    {
        this.targetRole = targetRole;
    }


    public RimCoreActs getControlAct()
    {
        return controlAct;
    }


    public void setControlAct(RimCoreActs controlAct)
    {
        this.controlAct = controlAct;
    }

    // public CS TypeCode;public IVL_TS existenceTime; public INT
    // priorityNumber;public CS relation; public CS describe;

    @Column(name = "EXISTENCE_START_DATE_TS")
    private Timestamp existenceStartDateTs;
    @Column(name = "EXISTENCE_END_DATE_TS")
    private Timestamp existenceEndDateTs;
    @Column(name = "EXISTENCE_DATE_TXT")
    private String existenceDateTxt;
    @Column(name = "EXISTENCE_DATE_IVL_TXT")
    private String existenceDateIvlTxt;
    @Column(name = "EXISTENCE_DATE_IVL_UOM_CODE")
    private String existenceDateIvlUomCode;

    @Column(name = "TYPE_CODE", nullable = false)
    private String typeCode;

    @Column(name = "PRIORITY_NUM")
    private Long priorityNumber;

    @Column(name = "RELATION_TYPE")
    private String relation;

    @Column(name = "DESCRIBE")
    private String describe;


    protected Long getRoleLinkId()
    {
        return roleLinkId;
    }


    protected void setRoleLinkId(Long roleLinkId)
    {
        this.roleLinkId = roleLinkId;
    }


    protected Timestamp getExistenceStartDateTs()
    {
        return existenceStartDateTs;
    }


    protected void setExistenceStartDateTs(Timestamp existenceStartDateTs)
    {
        this.existenceStartDateTs = existenceStartDateTs;
    }


    protected Timestamp getExistenceEndDateTs()
    {
        return existenceEndDateTs;
    }


    protected void setExistenceEndDateTs(Timestamp existenceEndDateTs)
    {
        this.existenceEndDateTs = existenceEndDateTs;
    }


    protected String getExistenceDateTxt()
    {
        return existenceDateTxt;
    }


    protected void setExistenceDateTxt(String existenceDateTxt)
    {
        this.existenceDateTxt = existenceDateTxt;
    }


    protected String getExistenceDateIvlTxt()
    {
        return existenceDateIvlTxt;
    }


    protected void setExistenceDateIvlTxt(String existenceDateIvlTxt)
    {
        this.existenceDateIvlTxt = existenceDateIvlTxt;
    }


    protected String getExistenceDateIvlUomCode()
    {
        return existenceDateIvlUomCode;
    }


    protected void setExistenceDateIvlUomCode(String existenceDateIvlUomCode)
    {
        this.existenceDateIvlUomCode = existenceDateIvlUomCode;
    }


    protected String getTypeCode()
    {
        return typeCode;
    }


    protected void setTypeCode(String typeCode)
    {
        this.typeCode = typeCode;
    }


    protected Long getPriorityNumber()
    {
        return priorityNumber;
    }


    protected void setPriorityNumber(Long priorityNumber)
    {
        this.priorityNumber = priorityNumber;
    }


    protected String getRelation()
    {
        return relation;
    }


    protected void setRelation(String relation)
    {
        this.relation = relation;
    }


    protected String getDescribe()
    {
        return describe;
    }


    protected void setDescribe(String describe)
    {
        this.describe = describe;
    }

}
